import torch
import torchvision
from torch.nn import Conv2d
from torch.utils.data import DataLoader
from torch import nn
from torch.utils.tensorboard import SummaryWriter

dataset = torchvision.datasets.CIFAR10(root=r"./dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataLoad = DataLoader(dataset, batch_size=64)
class Co_Module(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = Conv2d(in_channels=3, out_channels=6, kernel_size=3, stride=1, padding=0)

    def forward(self, x):
        x = self.conv1(x)
        return x

writer = SummaryWriter("./conv_logs")
step = 0
model = Co_Module()
for data in dataLoad:
    imgs, target = data
    output = model(imgs)
    writer.add_images('input', imgs, step)
    output = torch.reshape(output, (-1, 3, 30, 30))
    writer.add_images('output', output, step)
    step += 1

writer.close()